import { createRouter, createWebHistory } from 'vue-router';
import Layout from '@/layout/layout.vue';

const routes = [
  {
    path: '/login',
    component: () => import('@/views/login/login.vue'),
    hidden: true,
  },
  {
    path: '',
    component: Layout,
    redirect: 'home',
    children: [
      {
        path: 'home',
        component: () => import('@/views/home/home.vue'),
        name: 'home',
        meta: { title: '首页', icon: 'dashboard', affix: true },
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

router.afterEach((to) => {
  document.title = to.meta.title || '**管理系统';
});
export default router;
